package com.martian.mapper;

import com.martian.pojo.dto.*;
import com.martian.pojo.entity.Movie;
import com.martian.pojo.entity.MovieStatistic;
import com.martian.pojo.entity.UserStatistic;
import com.martian.pojo.form.LoadMovieForm;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Mapper
@Repository
public interface MovieMapper {
    List<Movie> getAllMovie();

    List<Movie> getAllMovieForSearchList();

    List<Movie> getAllMovieByName(String movieName);

    List<Movie> getAllMovieByGenre(String movieGenre);

    Integer getNumOfAllMovies();

    Integer getNumOfAllMoviesByGenre(String movieGenre);

    Integer getNumOfAllMoviesByName(String movieName);

    Integer getNumOfAllMovieCollect(Integer userId);

    Integer getNumOfAllMovieRating(Integer userId);

    void insertMovie(LoadMovieForm loadMovieForm);

    void editMovie(LoadMovieForm loadMovieForm);

    void deleteMovieById(Integer movieId);

    void batchDeleteMovie(List<Integer> deletedMovieId);

    void getDistinctUserIds();

    List<Integer> selectMovieIdsByGenres(String geners);

    List<Integer> selectMovieIdsByGenresAndYear(String geners,Integer targetYear,Integer span);

    List<Integer> selectUserRatingMovieIds(Integer userId);

    List<MovieStatistic> selectMovieStatisticsByGenres(String geners);

    List<MovieStatistic> selectMovieStatisticsByIds(List<Integer> candidateIds);

    MovieStatistic selectMovieStatisticsById(Integer movieId);

    List<RecMovieDto> selectMovieIdsByGenreOrderByAvgRating(Map map);

    List<RecMovieDto> selectMoviesByAvgRating(Integer size);

    List<RecMovieDto> selectMoviesByReleasedYear(Integer year,Integer span);

    List<RecMovieDto> selectRecMovieById(List<Integer> movieIds);

    List<RecMovieDto> selectMoviesByIds(List<Integer> movieIds);

    Movie selectMovieById(Integer movieId);

    List<Integer> getHotMovieIds(Integer size);

    /**
     * 获取已经存放数据表hotMovie中的id
     * @param size
     * @return
     */
    List<Integer> getHotedMovieIds(Integer size);

    MovieDetail selectMovieDetailById(Integer movieId);

    void insertMovieCollect(Integer userId, Integer movieId, Date date);

    Integer selectIsMovieCollect(Integer userId, Integer movieId);

    void deleteMovieCollect(Integer userId, Integer movieId);

    void insertMovieRating(Integer userId, Integer movieId, double movieRating,Date date);

    void updateMovieRating(Integer userId, Integer movieId, double movieRating,Date date);

    Double selectMovieRating(Integer userId, Integer movieId);

    List<Integer> selectMovieIdsByAvgRating();

    double selectUserRatingStd(Integer userId);

    UserStatistic selectUserRatingAvgYearAndStd(Integer userId);

    double selectUserRatingYearStd(Integer userId);

    void insertMovieStatistic(MovieStatistic movieStatistic);

    void updateMovieStatistic(MovieStatistic movieStatistic);

    MovieStatistic selectMovieAvgRating(Integer movieId);

    Double selectMovieRatingStd(Integer movieId);

    Integer selectAllMovieNum();

    List<UserRatingHistory> selectMoviesForUserHistory(UserScanHistoryDto userScanHistoryDto);

    List<RecMovieDto> selectRecMovieByIdInRedis(MovieSimilarDto movieSimilarDto);
}
